<?php
/**
* @version   $Id: scribblemaps.php 3 2010-10-05 09:21:31Z edo888 $
* @package   Scribble Maps
* @copyright Copyright (C) 2010 Edvard Ananyan. All rights reserved.
* @license   GNU/GPL, see LICENSE.php
*/

defined("_JEXEC") or die("Restricted access");

jimport('joomla.application.component.controller');

class ScribbleMapsController extends JController {
    function __construct($default = array()) {
        parent::__construct($default);
    }

    function display() {
        $id = JRequest::getInt('map_id');
        $db =& JFactory::getDBO();
        $db->setQuery("select * from #__scribblemaps where id = '$id'");
        $map = $db->loadObject();

        if(!is_object($map))
            JError::raiseError(404, "Map doesn't exist");
    ?>
    <h2><?php echo $map->title; ?></h2>
    <p><?php echo $map->description; ?></p>
    <?php
    /*
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="<?php echo $map->width; ?>" height="<?php echo $map->height; ?>" id="smwidget" align="middle">
        <param name="allowFullScreen" value="true" />
        <param name="allowscriptaccess" value="always" />
        <param name="FlashVars" value="mt=true&p=true&d=true&l=false&z=true&id=<?php echo $map->map_id; ?>" />
        <param name="movie" value="http://widgets.scribblemaps.com/smwidget.swf"/>
        <param name="quality" value="high" />
        <param name="bgcolor" value="#" />
        <embed src="http://widgets.scribblemaps.com/smwidget.swf" FlashVars="mt=true&p=true&d=true&l=false&z=true&id=<?php echo $map->map_id; ?>" allowscriptaccess="always" quality="high" bgcolor="#" width="<?php echo $map->width; ?>" height="<?php echo $map->height; ?>" name="smwidget" align="middle" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
    </object>
    */
    ?>
    <iframe width="<?php echo $map->width; ?>" height="<?php echo $map->height; ?>" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?q=http:%2F%2Fwww.scribblemaps.com%2Fgetkml.aspx%3Fid%3D<?php echo $map->map_id; ?>&amp;ie=UTF8&amp;output=embed"></iframe>
    <br /><small><a href="http://maps.google.com/maps?q=http:%2F%2Fwww.scribblemaps.com%2Fgetkml.aspx%3Fid%3D<?php echo $map->map_id; ?>&amp;ie=UTF8&amp;z=7&amp;source=embed" style="color:#0000FF;text-align:left" target="_blank">View Larger Map</a></small>
    <?php
    }
}

$controller = new ScribbleMapsController(array('default_task' => 'display'));
$task = JRequest::getVar('task');
$controller->execute(JRequest::getVar('task'));
$controller->redirect();